import { Toast } from 'vant'
import util from './validate'
/**
 * 通用路由跳转
 */
export default {

    /**
     * 总局（局机关）页面跳转，统一提出来，用的地方较多，方便修改
     * @param configCode
     * @param proInstId
     * @param from -- search 打开后只查看详情，没有操作按钮，为空则正常显示按钮
     */
    toCaac(configCode,proInstId,from=''){
        if(configCode=='mhj_fw'){//发文（函）
            uni.navigateTo({
                url:"/pages/caac/send/index?proInstId="+proInstId+"&from="+from
            })
        }else if(configCode=='jbhlc'){//局内便函
            uni.navigateTo({
                url:"/pages/caac/jnbh/index?proInstId="+proInstId+"&from="+from
            })
        }else if(configCode=='sj_sw'){//司局收文
            uni.navigateTo({
                url:"/pages/caac/sjsw/index?proInstId="+proInstId+"&from="+from
            })
        }else if(configCode=='mhj_cpj'){//glj_cpj--呈批件
            //跳转呈批件
            uni.navigateTo({
                url:"/pages/caac/submit/index?proInstId="+proInstId+"&from="+from
            })

        }else if(configCode=='fd_j'){// fd_hbglj--发电
            //跳转发电
            uni.navigateTo({
                url:"/pages/caac/sendMsg/index?proInstId="+proInstId+"&from="+from
            })

        }else if(configCode=='mhjfd'){//hbgljfd--发电抄阅
            //跳转发电抄阅
            uni.navigateTo({
                url:"/pages/caac/sendMsgCopy/index?proInstId="+proInstId+"&from="+from
            })
        }else if(configCode=='mhjsd'){//hbgljfd--收电批办
            //跳转收电批办
            uni.navigateTo({
                url:"/pages/caac/receiveMsgApproval/index?proInstId="+proInstId+"&from="+from
            })
        }else if(configCode=='mhj_sw_zhu'){// glj_sw收文
            // 跳转收文详情
            uni.navigateTo({
                url:"/pages/caac/receive/index?proInstId="+proInstId+"&from="+from
            })
        }else{
            Toast('其他公文类型正在开发中，敬请期待!')
        }
    },

    /**
     * 管理局页面跳转，统一提出来，用的地方较多，方便修改
     * @param configCode
     * @param proInstId
     * @param from -- search 打开后只查看详情，没有操作按钮，为空则正常显示按钮
     */
    toAdmin(configCode,proInstId,from){
        if(configCode=='glj_fw'){//发文（函）
            uni.navigateTo({
                url:"/pages/admin/send/index?proInstId="+proInstId+"&from="+from
            })
        }else if(configCode=='hqj'){//发文（函）-会签件
            uni.navigateTo({
                url:"/pages/admin/send/index?proInstId="+proInstId+"&from="+from
            })
        }else if(configCode=='glj_cpj'){//glj_cpj--呈批件
            //跳转呈批件
            uni.navigateTo({
                url:"/pages/admin/submit/index?proInstId="+proInstId+"&from="+from
            })
        }else if(configCode=='fd_hbglj'){// fd_hbglj--发电
            //跳转发电
            uni.navigateTo({
                url:"/pages/admin/sendMsg/index?proInstId="+proInstId+"&from="+from
            })
        }else if(configCode=='hbgljfd'){//hbgljfd--发电抄阅
            //跳转发电抄阅
            uni.navigateTo({
                url:"/pages/admin/sendMsgCopy/index?proInstId="+proInstId+"&from="+from
            })
        }else if(configCode=='hbgljsdzlc'){//hbgljfd--收电批办
            //跳转收电批办
            uni.navigateTo({
                url:"/pages/admin/receiveMsgApproval/index?proInstId="+proInstId+"&from="+from
            })
        }else if(configCode=='glj_sw'){// glj_sw收文
            // 跳转收文详情
            uni.navigateTo({
                url:"/pages/admin/receive/index?proInstId="+proInstId + "&from="+from
            })
        }else{
            Toast('其他公文类型正在开发中，敬请期待!')
        }

    },

    /**
     * 监管局页面跳转，统一提出来，用的地方较多，方便修改
     * @param configCode
     * @param proInstId
     * @param from -- search 打开后只查看详情，没有操作按钮，为空则正常显示按钮
     */
    toJgj(configCode,proInstId,from){
        if(configCode =='jgj_fw'){//发文（函）
            uni.navigateTo({
                url:"/pages/jgj/send/index?proInstId="+proInstId+"&from="+from
            })
        }else if(configCode == 'hqj'){//TODO 公文流转发文（函）-会签件
            uni.navigateTo({
                url:"/pages/jgj/send/index?proInstId="+proInstId+"&from="+from
            })
        }else if(configCode=='hbjgj_cpj'){//glj_cpj--呈批件
            //跳转呈批件
            uni.navigateTo({
                url:"/pages/jgj/submit/index?proInstId="+proInstId+"&from="+from
            })
        }else if(configCode=='hbjgjgwfd'){// fd_hbglj--发电
            //跳转发电
            uni.navigateTo({
                url:"/pages/jgj/sendMsg/index?proInstId="+proInstId+"&from="+from
            })
        }else if(configCode=='hbjgjfd'){//hbgljfd--发电抄阅
            //跳转发电抄阅
            uni.navigateTo({
                url:"/pages/jgj/sendMsgCopy/index?proInstId="+proInstId+"&from="+from
            })
        }else if(configCode=='hbjgjsd'){//hbgljfd--收电批办
            //跳转收电批办
            uni.navigateTo({
                url:"/pages/jgj/receiveMsgApproval/index?proInstId="+proInstId+"&from="+from
            })
        }else if(configCode == 'hbjgjsw'){// glj_sw收文
            // 跳转收文详情
            uni.navigateTo({
                url:"/pages/jgj/receive/index?proInstId="+proInstId+"&from="+from
            })
        }else{
            Toast('其他公文类型正在开发中，敬请期待!')
        }
    },

    /**
     * 根据app类型跳转不同首页
     * @param deptName 当前用户所属局
     * @param type app类型
     */
    toIndexByType(deptName, type) {
        let isAdmin = deptName.indexOf('管理') != -1;
        let isJgj = deptName.indexOf('监管') != -1;
        let url = isAdmin ? 'admin' : (isJgj ? 'jgj' : 'caac');

        if (deptName.indexOf('管理') != -1 || deptName.indexOf('监管') != -1) {
            // 如果type为空或为oa跳转管理局首页
            if (util.isEmpty(type) || type === 'oa') {
                uni.redirectTo({
                    url: '/pages/' + url +'/index/index'
                })
            } else if (type === 'gljdb') {
                // 待办文件
                uni.redirectTo({
                    url: '/pages/' + url +'/send/signList'
                })
            } else if (type === 'trace') {
                // 跟踪
                uni.redirectTo({
                    url: '/pages/' + url +'/index/trace'
                })
            } else if (type === 'collect') {
                // 收藏
                uni.redirectTo({
                    url: '/pages/' + url +'/index/collection'
                })
            } else if (type === 'search') {
                // 查询
                uni.redirectTo({
                    url: '/pages/' + url +'/index/search'
                })
            } else if (type === 'dclsw') {
                // 待处理收文
                uni.redirectTo({
                    url: '/pages/' + url +'/receive/todoDoc'
                })
            } else if (type === 'dsld') {
                // 待收来电
                uni.redirectTo({
                    url: '/pages/' + url +'/receiveMsg/receive-call'
                })
            } else if (type === 'news') {
                // 新闻
                uni.redirectTo({
                    url: '/pages/' + url +'/components/newsList/compo-index'
                })
            } else if (type === 'notice') {
                // 通知公告
                uni.redirectTo({
                    url: '/pages/' + url +'/components/newsList/compo-notice'
                })
            } else if (type === 'wdcx') {
                // 文电查询
                uni.redirectTo({
                    url: '/pages/' + url +'/components/newsList/compo-index?activeName=mhjwd'
                })
            } else if (type === 'cwbxzd') {
                // 财务报销制度
                uni.redirectTo({
                    url: '/pages/' + url +'/components/newsList/compo-cwbxzd'
                })
            } else {
                uni.redirectTo({
                    url: '/pages/' + url +'/index/index'
                })
            }
        } else {
            // 如果type为空或为oa跳转管理局首页
            if (util.isEmpty(type) || type === 'oa') {
                uni.redirectTo({
                    url: '/pages/' + url +'/index/index'
                });
            } else if (type === 'dbwj') {
                // 待办文件
                uni.redirectTo({
                    url: '/pages/' + url +'/send/signList'
                })
            } else if (type === 'dbdb') {
                // 待办电报
                uni.redirectTo({
                    url: '/pages/' + url +'/send/signListdb'
                })
            } else if (type === 'trace') {
                // 跟踪
                uni.redirectTo({
                    url: '/pages/' + url +'/index/trace'
                })
            } else if (type === 'collect') {
                // 收藏
                uni.redirectTo({
                    url: '/pages/' + url +'/index/collection'
                })
            } else if (type === 'search') {
                // 查询
                uni.redirectTo({
                    url: '/pages/' + url +'/index/search'
                })
            } else if (type === 'dclsw') {
                // 待处理收文
                uni.redirectTo({
                    url: '/pages/' + url +'/receive/todoDoc'
                })
            } else if (type === 'dsld') {
                // 待收来电
                uni.redirectTo({
                    url: '/pages/' + url +'/receiveMsg/receive-call'
                })
            } else if (type === 'news') {
                // 新闻
                uni.redirectTo({
                    url: '/pages/' + url +'/components/newsList/compo-index'
                })
            } else if (type === 'notice') {
                // 通知公告
                uni.redirectTo({
                    url: '/pages/' + url +'/components/newsList/compo-notice'
                })
            } else if (type === 'wdcx') {
                // 文电查询
                uni.redirectTo({
                    url: '/pages/' + url +'/components/newsList/compo-index?activeName=mhjwd'
                })
            } else if (type === 'cwbxzd') {
                // 财务报销制度
                uni.redirectTo({
                    url: '/pages/' + url +'/components/newsList/compo-cwbxzd'
                })
            } else {
                uni.redirectTo({
                    url: '/pages/' + url +'/index/index'
                });
            }
        }
    },

}
